package com.fmh.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fmh.mybatisplus.pojo.Role;
import com.fmh.mybatisplus.service.RoleService;
import com.fmh.mybatisplus.mapper.RoleMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 27713
* @description 针对表【sys_role(角色表)】的数据库操作Service实现
* @createDate 2023-05-06 10:22:42
*/
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
    implements RoleService{

    @Override
    public List<Role> listRolesByUserId(Long userId) {
        // 先从sys_user_role关联表查出role

        List<Role> roles = this.list(new QueryWrapper<Role>()
                .inSql("id", "select role_id from sys_user_role where deleted = 0 and user_id =" + userId));

        return roles;
    }
}




